package com.oceanread.cn.config;

import com.baomidou.mybatisplus.core.parser.ISqlParser;
import com.baomidou.mybatisplus.extension.parsers.BlockAttackSqlParser;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.ArrayList;

/**
 * @author konglingxuan
 * @date 2021/11/1
 */
@EnableTransactionManagement
@Configuration
@MapperScan({"com.oceanread.cn.mapper*"})
public class MybatisPlusConfig {
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        paginationInterceptor.setSqlParserList(new ArrayList<ISqlParser>() {
            {
                this.add(new BlockAttackSqlParser());
            }
        });
        return paginationInterceptor;
    }
}
